
<template>
     <Form  ref="form" :model="formData" :label-width="100">
        <FormItem prop="organizationId" label="账户组织:"  :rules="required">
            <Select  v-model="formData.organizationId" filterable clearable>
                <Option v-for="item in getSysAllList" :value="item.value" :key="item.value">{{item.label}}</Option>
            </Select>
        </FormItem>
        <FormItem prop="amount" label="冻结金额:"  :rules="required">
            <Input  v-model="formData.amount"/>
        </FormItem>
        <FormItem label="冻结原因:">
            <Input  v-model="formData.cause" type='textarea'/>
        </FormItem>
        <footer class="text-right">
            <Button type="primary" @click="submit">保存</Button>
            <Button class="margin-left-10" @click="close">返回</Button>
            <Spin size="large" fix v-if="loading"></Spin>
        </footer>
    </Form>
</template>

<script>
import { HttpAddFinanceFrozen } from '@/service/api/views';
import { mapGetters } from 'vuex';
export default {

    data() {
        return {
            loading: false,
            formData: {
                organizationName: '',
                amount: "",
                cause: "",
            },
            required: [{
                required: true,
                message: "该信息不能为空,请填写"
            }],
        };
    },
  
    computed: {
        ...mapGetters('dictionary',['getSysAllList']),
    },
    methods: {
        close() {
            this.$emit('on-update');
            this.$emit('on-close');
        },
        async submit() {
            let valid = this.$refs['form'].validate();
            if (!valid) return;
            this.loading = true;
            this.formData.organizationName = this.getSysAllList.filter(item=>{ return item.value == this.formData.organizationId})[0].label;
            HttpAddFinanceFrozen({...this.formData}).then(res => {
                this.close();
                this.$Message.success(res.message);
            }, err => {
                this.$Message.error(err.message);
            }).finally(result => {
                this.loading = false;
            })
        },


    },
};
</script>
